<?php
// 应用公共文件

function pe($data)
{
    print_r($data);exit();
}

function de($data)
{
    dump($data);exit();
}

function msg($code, $msg, $data)
{
    return compact('code', 'msg', 'data');
}

function getJson($code = 200, $msg = '', $data = null)
{
    return json(msg($code, $msg, $data));
}

function getErrorJson($msg = '操作失败', $data = null)
{
    return json(msg(201, $msg, $data));
}

function getJsonEncode($data = [])
{
    return json_encode($data, JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE);
}

function get404Content()
{
    return "<html><head><title>404 Not Found</title></head><body><center><h1>404 Not Found</h1></center><hr><center>nginx</center></body></html>";
}

function isTimestamp($timestamp) {
    if(is_numeric($timestamp) && strlen(strval($timestamp)) == 10 && $timestamp > 0 && $timestamp <= 2147483647 && strtotime(date('Y-m-d H:i:s',$timestamp)) == $timestamp) {
        return true;
    } else {
        return false;
    }
}